#include <stdio.h>
#include <pthread.h>
#include <unistd.h>

int n;
pthread_cond_t cond;
pthread_mutex_t lock;

void* fun(void* argv){

  pthread_mutex_lock(&lock);

  pthread_cond_wait(&cond,&lock);

  if(n == 5){
    printf("ni hao\n");
  }else{
    while(1){
      sleep(1);
    }
  }

  pthread_mutex_unlock(&lock);
    
  pthread_exit(NULL);
}

int main(int argc,char* argv[]){
  pthread_cond_init(&cond,NULL);
  pthread_mutex_init(&lock,NULL);
  
  pthread_t tid;
  pthread_create(&tid,NULL,fun,NULL);

  sleep(2);
  n = 0;
  n = 5;
  pthread_cond_signal(&cond);


  pthread_cond_destroy(&cond);
  pthread_mutex_destroy(&lock);
  pthread_exit(NULL);
}
